package com.crois.barrier.web.spring;

import com.crois.barrier.plugin.BarrierPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author Hou Ze Yu
 * @description barrier插件BeanPostProcess
 * @date 2020/5/7
 */
@Component
public class BarrierPluginBeanPostProcessor implements BeanPostProcessor {

    private Logger log= LoggerFactory.getLogger(getClass());

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof BarrierPlugin) {
            BarrierPlugin dp=(BarrierPlugin)bean;
            log.info("barrier find pluging:[{}]\t[ {} ]\t[{}]",dp.name(),dp.getClass().getName(),dp.pluginType());
        }
        return bean;
    }
}
